package sk.gtug.hackatlon.drunkdroid;

import sk.vasicek.drinkmanager.activity.DrinkManagerActivity;
import android.app.Activity;
import android.content.Intent;
import android.media.SoundPool;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.Toast;

public class MainActivity extends Activity {
	public static SoundPool mPlayer = null;
	public static int mPlayBurp;
	public static int mPlayGlass;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.main);
		if ( mPlayer == null ) {
			mPlayer = new SoundPool(100, android.media.AudioManager.STREAM_MUSIC, 0);
		}
		if ( mPlayer != null ) {
			mPlayGlass = mPlayer.load(this, R.raw.glass, 1);
			mPlayBurp = mPlayer.load(this, R.raw.burp, 1);
		} else {
			Toast.makeText(this, "Nepodarilo sa vytvorit player!", Toast.LENGTH_SHORT);
		}


		ImageButton screen1Button = (ImageButton) this.findViewById(R.id.screen1Button);
		ImageButton screen2Button = (ImageButton) this.findViewById(R.id.screen2Button);
		ImageButton drinkManagerButton = (ImageButton) this.findViewById(R.id.drinkManagerButton);
		//		Button screen3Button = (Button) this.findViewById(R.id.screen3Button);
		//		Button drinkCounterButton = (Button) this.findViewById(R.id.drinkCounterButton);
		screen1Button.setOnClickListener(new View.OnClickListener(){
			@Override
			public void onClick(View view) {
				Intent intent = new Intent(view.getContext(), Activity1Main.class);
				MainActivity.this.startActivity(intent);
			}
		});
		screen2Button.setOnClickListener(new View.OnClickListener(){
			@Override
			public void onClick(View view) {
				Intent intent = new Intent(view.getContext(), Activity2Main.class);
				MainActivity.this.startActivity(intent);
			}
		});
		drinkManagerButton.setOnClickListener(new View.OnClickListener(){
			@Override
			public void onClick(View view) {
				Intent intent = new Intent(view.getContext(), DrinkManagerActivity.class);
				MainActivity.this.startActivity(intent);
			}
		});
		//		screen3Button.setOnClickListener(new View.OnClickListener(){
		//			@Override
		//			public void onClick(View view) {
		//				Intent intent = new Intent(view.getContext(), Activity3.class);
		//				MainActivity.this.startActivity(intent);
		//			}
		//		});
		//		drinkCounterButton.setOnClickListener(new View.OnClickListener(){
		//			@Override
		//			public void onClick(View view) {
		//				Intent intent = new Intent(view.getContext(), DrinkCounterActivity.class);
		//				MainActivity.this.startActivity(intent);
		//			}
		//		});
	}
	
	@Override
	public void onDestroy() {
		if ( mPlayer != null ) {
			mPlayer.release();
			mPlayer = null;
		}
		super.onDestroy();
	}
}